﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.GERP.GFMS.MODEL;
using KPIS.GERP.GFMS.IBLL;
using KPIS.GERP.GFMS.IDAL;
using KPIS.GERP.GFMS.DALFactory;

// test only
using KPIS.GERP.GFMS.DAL;

namespace KPIS.GERP.GFMS.BLL
{
    public class B_FIM_MoneyRequestTravelers : IBLL_FIM_MoneyRequestTravelers
    {
        Common common = new Common();
        private static readonly IDAL_FIM_MoneyRequestTravelers dal = DataAccess.Create_FIM_MoneyRequestTravelers();

        public B_FIM_MoneyRequestTravelers()
        {

        }

        public DataTable GetFull(string money_req_seq)
        {
            Nullable<int> nmoney_req_seq = common.ConvertNullInt(money_req_seq);
            return dal.GetFull(nmoney_req_seq);
        }

        public DataTable GetList(string money_req_seq)
        {
            Nullable<int> nmoney_req_seq = common.ConvertNullInt(money_req_seq);
            return dal.GetList(nmoney_req_seq);
        }

        public DataRow GetInfo(string seq)
        {
            int nSeq;

            if (seq == null)
                return null;

            if (common.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfo(nSeq);
            }
            else
            {
                return null;
            }
        }

        public void Insert(string money_req_seq
            , string emp_seq
            , string contact_seq
            , string contact_person_seq
            , string job_site_seq
            , string pos_seq
            , string class_seq
            , string old_class_seq
            , string record_status
            , string created_by)
        {
            Nullable<int> _money_req_seq = common.ConvertNullInt(money_req_seq);
            Nullable<int> _emp_seq = common.ConvertNullInt(emp_seq);
            Nullable<int> _contact_seq = common.ConvertNullInt(contact_seq);
            Nullable<int> _contact_person_seq = common.ConvertNullInt(contact_person_seq);
            Nullable<int> _job_site_seq = common.ConvertNullInt(job_site_seq);
            Nullable<int> _pos_seq = common.ConvertNullInt(pos_seq);
            Nullable<int> _class_seq = common.ConvertNullInt(class_seq);
            Nullable<int> _old_class_seq = common.ConvertNullInt(old_class_seq);
            string _record_status = record_status;
            Nullable<int> _created_by = common.ConvertNullInt(created_by);
            DateTime _created_when = DateTime.Today;

            try
            {
                dal.Insert(_money_req_seq
                    , _emp_seq
                    , _contact_seq
                    , _contact_person_seq
                    , _job_site_seq
                    , _pos_seq
                    , _class_seq
                    , _old_class_seq
                    , _record_status
                    , _created_by
                    , _created_when);
            }
            catch
            {
                throw;
            }
        }

        public void Update(string traveler_seq
            , string money_req_seq
            , string emp_seq
            , string contact_seq
            , string contact_person_seq
            , string job_site_seq
            , string pos_seq
            , string class_seq
            , string old_class_seq
            , string updated_by)
        {
            int _traveler_seq = Convert.ToInt32(traveler_seq);
            Nullable<int> _money_req_seq = common.ConvertNullInt(money_req_seq);
            Nullable<int> _emp_seq = common.ConvertNullInt(emp_seq);
            Nullable<int> _contact_seq = common.ConvertNullInt(contact_seq);
            Nullable<int> _contact_person_seq = common.ConvertNullInt(contact_person_seq);
            Nullable<int> _job_site_seq = common.ConvertNullInt(job_site_seq);
            Nullable<int> _pos_seq = common.ConvertNullInt(pos_seq);
            Nullable<int> _class_seq = common.ConvertNullInt(class_seq);
            Nullable<int> _old_class_seq = common.ConvertNullInt(old_class_seq);
            Nullable<int> _updated_by = common.ConvertNullInt(updated_by);
            DateTime _updated_when = DateTime.Today;

            try
            {
                dal.Update(_traveler_seq
                    , _money_req_seq
                    , _emp_seq
                    , _contact_seq
                    , _contact_person_seq
                    , _job_site_seq
                    , _pos_seq
                    , _class_seq
                    , _old_class_seq
                    , _updated_by
                    , _updated_when);
            }
            catch
            {
                throw;
            }
        }

        public void Delete(string traveler_seq
            , string updated_by)
        {
            int _travaler_seq = Convert.ToInt32(traveler_seq);
            Nullable<int> _updated_by = common.ConvertNullInt(updated_by);
            DateTime _updated_when = DateTime.Today;

            try
            {
                dal.Delete(_travaler_seq
                    , _updated_by
                    , _updated_when);
            }
            catch
            {
                throw;
            }
        }
    }
}
